
#任务中 新建任务页面类

from selenium.webdriver.common.by import By
from page.base_page import BasePage

class NewtaskPage(BasePage):
    url = "/crm/index.php?m=task&a=add"

# 新建任务输入框任务定位器
    task_locator = (By.LINK_TEXT, '任务')  # 任务模块
    newtask_locator = (By.LINK_TEXT, '新建任务')  # 新建任务
    subiect_locator = (By.ID, 'subject')  # 添加任务中的主题

    principal_locator = (By.ID, 'owner_name')  # 添加任务中负责人
    entirebtn_locator = (By.XPATH, '//*[@id="ta1"]/span[1]/input')  # 选择添加任务中第一位admin负责人
    entirebtnmax_locator = (By.XPATH, '/html/body/div[7]/div[2]/form/div[1]/input')  # 选择添加任务中全部负责人
    okbtn_locator = (By.XPATH, '/html/body/div[7]/div[3]/div/button[1]')  # 选择添加任务中选择负责人ok按钮

    correlation_locator = (By.ID, 'about_roles_name')  # 选择任务相关人
    correlation_principal_locator = (By.XPATH, '//*[@id="ta1"]/span[1]/input')  # 选择添加任务相关人第一位
    correlationmax_principal_locator = (By.XPATH, '//*[@id="ta1"]/input')  # 选择添加任务相关人全部负责人
    correlation_okbtn_locator = (By.XPATH, '/html/body/div[8]/div[3]/div/button[1]')  # 任务相关人点击ok保存

    belowchoice_locator = (By.XPATH, '//*[@id="select1"]')  # 选择相关下拉框
    belowtwochoice_locator = (By.XPATH, '//*[@id="select1"]/option[2]')  # 选择下拉框第二个   联系人
    choice_locator = (By.ID, 'module_name')  # 选择相关框
    onechoice_locator = (By.XPATH, '/html/body/div[9]/div[2]/table/tbody[2]/tr[1]/td[1]/input')  # 选择第一个相关人
    okchoice_locator = (By.XPATH, '/html/body/div[9]/div[3]/div/button[1]')  # 相关点击ok

    informmail_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[2]/td[4]/input[2]')  # 发送通知 邮件
    informletter_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[2]/td[4]/input[1]')  # 发送通知 站内信

    priority_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[6]/td[4]/select')  # 优先级框
    priority_low_locator = (
    By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[6]/td[4]/select/option[3]')  # 优先级低

    describe_locator = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tbody/tr[7]/td[2]/div/div[2]/iframe')  # 描述内容
    save_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]')  # 添加任务中的保存按钮

    xinjianbaocun = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[2]')  #新建并保存
    fanhui = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[3]') #返回

    tianjiachenggong = (By.XPATH,'/html/body/div[5]/div[2]/div/div')



    # 获取当前页面地址
    def get_current_url(self):
        return self.driver.current_url

    #输入主题内容
    def input_subiect(self,subiect):
        self.driver.find_element(*self.subiect_locator).send_keys(subiect)

    #点击任务中的负责人
    def click_principal(self):
        self.driver.find_element(*self.principal_locator).click()

    #选择添加任务中admin负责人
    def click_entirebtn(self):
        self.driver.find_element(*self.entirebtn_locator).click()

    # #选择添加任务中全部负责人
    def click_entirebtnmax(self):
        self.driver.find_element(*self.entirebtnmax_locator).click()

    #选择好后点击ok
    def click_okbtn(self):
        self.driver.find_element(*self.okbtn_locator).click()

    #选择任务相关人
    def click_correlation(self):
        self.driver.find_element(*self.correlation_locator).click()

    #选择添加任务相关第一位
    def click_correlation_principl(self):
        self.driver.find_element(*self.correlation_principal_locator).click()

    #选择添加相关任务全部负责人
    def click_correlationmax_principl(self):
        self.driver.find_element(*self.correlationmax_principal_locator).click()

    #任务相关人点击ok保存
    def click_correlation_okbtn(self):
        self.driver.find_element(*self.correlation_okbtn_locator).click()

    #选择相关下拉框
    def click_belowchoice(self):
        self.driver.find_element(*self.belowchoice_locator).click()

    #选择下拉框第二个联系人
    def click_belowtwochoice(self):
        self.driver.find_element(*self.belowtwochoice_locator).click()

    #选择相关框
    def click_choice(self):
        self.driver.find_element(*self.choice_locator).click()

    #选择第一个相关人
    def click_onechoice(self):
        self.driver.find_element(*self.onechoice_locator).click()

    #点击相关ok
    def click_okchoice(self):
        self.driver.find_element(*self.okchoice_locator).click()

    #发送通知 点击邮件
    def click_informmail(self):
        self.driver.find_element(*self.informmail_locator).click()

    #发送通知 点击站内信
    def click_inforlatter(self):
        self.driver.find_element(*self.informletter_locator).click()

    #点击优先级
    def click_priority(self):
        self.driver.find_element(*self.priority_locator).click()

    #点击选择低
    def click_priority_low(self):
        self.driver.find_element(*self.priority_low_locator).click()

    #输入描述内容
    def input_describe(self,describe):
        self.driver.find_element(*self.describe_locator).send_keys(describe)

    #点击保存按钮
    def click_save(self):
        self.driver.find_element(*self.save_locator).click()

    #新建并保存按钮
    def click_xinjianbaocun(self):
        self.driver.find_element(*self.xinjianbaocun).click()

    #返回按钮
    def click_fanhui(self):
        self.driver.find_element(*self.fanhui).click()


    #添加成功定位器
    def text_tianjia(self):
        return self.driver.find_element(*self.tianjiachenggong).get_attribute("class")

    def url_dizhi(self):
        return self.driver.current_url()